<?php
$this->pageTitle = Yii::app()->name . ' - ' . AdmincpModule::t("Registration");
?>

<div id="content-header">
    <?php
    $this->widget('bootstrap.widgets.TbBreadcrumbs', array(
        'links' => array('Users' => array('user/index'), 'Thêm mới thành viên'),
        'htmlOptions' => array('id' => 'breadcrumb')
    ));
    ?>
</div>

<?php if (Yii::app()->user->hasFlash('registration')): ?>
    <div class="success">
        <?php echo Yii::app()->user->getFlash('registration'); ?>
    </div>
<?php else: ?>
    <div class="widget-box">
        <div class="widget-title">
            <span class="icon">
                <i class="icon-align-justify"></i>
            </span>
            <h5>Thêm mới</h5>
        </div>
        <div class="widget-content nopadding">
            <div class="widget-container">
                <?php
                $form = $this->beginWidget('UActiveForm', array(
                    'id' => 'registration-form',
                    'enableAjaxValidation' => true,
                    'disableAjaxValidationAttributes' => array('RegistrationForm_verifyCode'),
                    'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                ));
                ?>
                <?php // echo $form->errorSummary(array($model, $profile)); ?>
                <div class="control-group">
                    <?php echo $form->labelEx($model, 'username', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->textField($model, 'username'); ?>
                        <?php echo $form->error($model, 'username'); ?>
                    </div>
                </div>

                <div class="control-group">
                    <?php echo $form->labelEx($model, 'password', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->passwordField($model, 'password'); ?>
                        <?php echo $form->error($model, 'password'); ?>
                        <p class="hint">
                            <?php echo AdmincpModule::t("Minimal password length 4 symbols."); ?>
                        </p>
                    </div>
                </div>

                <div class="control-group">
                    <?php echo $form->labelEx($model, 'verifyPassword', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->passwordField($model, 'verifyPassword'); ?>
                        <?php echo $form->error($model, 'verifyPassword'); ?>
                    </div>
                </div>

                <div class="control-group">
                    <?php echo $form->labelEx($model, 'email', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->textField($model, 'email'); ?>
                        <?php echo $form->error($model, 'email'); ?>
                    </div>
                </div>

                <?php
                $profileFields = $profile->getFields();
                if ($profileFields) {
                    foreach ($profileFields as $field) {
                        ?>
                        <div class="control-group">

                            <?php echo $form->labelEx($profile, $field->varname, array('class' => 'control-label')); ?>
                            <div class="controls">
                                <?php
                                if ($field->widgetEdit($profile)) {
                                    echo $field->widgetEdit($profile);
                                } elseif ($field->range) {
                                    echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
                                } elseif ($field->field_type == "TEXT") {
                                    echo$form->textArea($profile, $field->varname, array('control-groups' => 6, 'cols' => 50));
                                } else {
                                    echo $form->textField($profile, $field->varname, array('size' => 60, 'maxlength' => (($field->field_size) ? $field->field_size : 255)));
                                }
                                ?>
                                <?php echo $form->error($profile, $field->varname); ?>
                            </div>
                        </div>	
                        <?php
                    }
                }
                ?>
                <div class="control-group">
                    <?php echo $form->labelEx($model, 'role', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo CHtml::activeDropDownList($model, 'role', Authitem::roleArray()); ?>
                        <?php echo $form->error($model, 'role'); ?>
                    </div>
                </div>
                <?php if (AdmincpModule::doCaptcha('registration')): ?>
                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'verifyCode', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textField($model, 'verifyCode'); ?>
                            <?php $this->widget('CCaptcha'); ?>
                            <?php echo $form->error($model, 'verifyCode'); ?>
                            <p class="hint"><?php echo AdmincpModule::t("Please enter the letters as they are shown in the image above."); ?>
                                <br/><?php echo AdmincpModule::t("Letters are not case-sensitive."); ?></p>
                        </div>
                    </div>
                <?php endif; ?>


                <div class="form-actions">
                    <?php echo CHtml::submitButton(AdmincpModule::t("Register"),array('class'=>'pull-right btn btn-success')); ?>
                </div>

                <?php $this->endWidget(); ?>
            </div><!-- form -->
        <?php endif; ?>
    </div>
</div>